package com.corpgovernment.organization.enumm.budget;

import java.util.LinkedHashMap;
import java.util.Map;

public enum BudgetScopeEnum {

    DEP("1", "DEP", "部门"),
    COS("2", "COS", "成本中心"),

    PRO("3", "PRO", "项目");

    private String code;
    private String type;
    private String name;

    BudgetScopeEnum(String code, String type, String name) {
        this.code = code;
        this.type = type;
        this.name = name;
    }

    public String getCode() {
        return code;
    }

    public String getType() {
        return type;
    }

    public String getName() {
        return name;
    }

    private static Map<String, BudgetScopeEnum> codeMap = new LinkedHashMap<>();
    private static Map<String, BudgetScopeEnum> typeMap = new LinkedHashMap<>();

    static {
        for (BudgetScopeEnum budgetScopeEnum : BudgetScopeEnum.values()) {
            codeMap.put(budgetScopeEnum.getCode(), budgetScopeEnum);
            typeMap.put(budgetScopeEnum.getType(), budgetScopeEnum);
        }
    }

    public static BudgetScopeEnum getEnumByCode(String code) {
        return codeMap.get(code);
    }

    public static BudgetScopeEnum getEnumByType(String type) {
        return typeMap.get(type);
    }
}